package com.mm.base.config.web;

import org.springframework.format.Formatter;

import java.util.Arrays;
import java.util.Locale;

/**
 * @Description 布尔格式化器
 * @Date 2023/9/27 下午2:05
 * @Author yanglin
 **/
public class BooleanFormatter implements Formatter<Boolean> {

    private String[] trueTag = {"true", "1", "是", "有"};


    @Override
    public Boolean parse(String s, Locale locale) {
        return Arrays.asList(trueTag).contains(s);
    }

    @Override
    public String print(Boolean aBoolean, Locale locale) {
        return aBoolean ? "true" : "false";
    }
}
